<#assign css> </#assign>
<#assign js> 
<script type="text/javascript">
var saveSort = function() {
	var datas = {};
	$(".data-sort").each(function() {
		if ($(this).val() != "") {
			datas[$(this).attr("data-id")] = $(this).val();
		}
	});
	
	$.ajax({
        type: "post",
        cache:false,
        url:"saveSort",
        data:JSON.stringify(datas),
        contentType:"application/json",
        beforeSend : function(a, b, c) {
            index = layer.load(2)
        },
        success: function(data){
            layer.close(index)
            if (data.code == '0') {//返回成功处理自行编写
                layer.msg(data.msg,{time: 1500}, function() {
                	reloadPage();
                });
            }else{
                layer.msg(data.msg,  {time: 1500});
            }
        }
    });
}
</script>
</#assign>
<#import "/admin/common/home.html" as home>
<#escape x as (x)!"">
<@home.home pagecss=css pagejs=js>
<form action="list?dictCode=${param.dictCode}" id="pageListForm" method="post" class="form-inline">
	<div class="search">
		<div class="form-group">
			<input type="text" name="dictKey" value="${param.dictKey}" class="form-control" placeholder="请输入字典编码" />
		</div>
		<div class="form-group">
			<input type="text" name="dictValue" value="${param.dictValue}" class="form-control" placeholder="请输入字典值" />
		</div>
		<div class="form-group">
			<a href="javascript:;" class="btn btn-search " id="btn-search">查询</a>
		</div>
	</div>
	
	<div class="main-container">
		<div class="toolbar">
			<a href="javascript:;" class="btn btn-primary" onclick="admin.dialog(this);" data-width="680" data-height="500" data-url="form?dictCode=${param.dictCode}" data-title="新增字典">新增字典</a>
			<a href="javascript:;" class="btn btn-delete"
				onclick="tab.del(this);" data-url="delete?dictCode=${param.dictCode}" data-tips="确定批量删除选中的字典吗？">批量删除</a>
			<a href="javascript:;" class="btn btn-other"
				onclick="tab.updateState(this, 2);" data-url="updateState?dictCode=${param.dictCode}" data-tips="确定批量禁用选中的字典吗？">批量禁用</a> 
			<a href="javascript:;" class="btn btn-other"
				onclick="tab.updateState(this, 1);" data-url="updateState?dictCode=${param.dictCode}" data-tips="确定批量启用选中的字典吗？">批量启用</a>
			<a href="javascript:;" class="btn btn-default" onclick="tab.sort(this)" data-url="sort?dictCode=${param.dictCode}">保存排序</a>
		</div>
		<table class="table table-bordered table-hover">
			<caption class="caption none" id="chkedInfo">
				<div class="caption-table">
					你已经选择<em id="chkLength" class="chkNumber">0</em>条记录！ 
					<span class="none">选择的值是：<input type="text" name="chkTotal" id="chkTotalVal" value="" /></span>
				</div>
			</caption>
			<thead class="thead thead-more">
				<tr>
					<th class="ui-td-chk"><input type="checkbox" name="checkAll" id="chkAll" /></th>
					<th class="ui-td-no">序号</th>
					<th>字典编码</th>
					<th>字典值</th>
					<th>排序</th>
					<th class="ui-td-status">状态</th>
					<th style="min-width: 150px;">备注</th>
					<th class="ui-td-oper">操作</th>
				</tr>
			</thead>
			<tbody class="tbody mod-tbody">
				<#if page?? && page.list ?? && page.list?size gt 0>
				<#list page.list as item>
				<tr>
					<td class="ui-td-chk">
						<input type="checkbox" name="chkItem" value="${item.dictKey}" extVal="${item.dictKey}" />
					</td>
					<td class="ui-td-no">${item_index + 1}</td>
					<td>${item.dictKey}</a></td>
					<td>${item.dictValue!''}</td>
					<td>
						<input class="form-control data-sort" value="${item.sort}" data-id="${item.dictKey}" oninput="value=value.replace(/[^\d]/g,'')"/>
					</td>
					<td class="ui-td-status">
						<#if item.state==1>
							<span class="status-yes">启用</span>
						<#else>
							<span class="status-no">禁用</span>
						</#if>
					</td>
					<td>${item.remarks!''}</td>
					<td class="ope-color">
						<a href="javascript:;" class="ui-ico-tips ui-ico-edit" onclick="admin.dialog(this);" data-width="680" data-height="500" title="编辑" data-url="form?dictCode=${param.dictCode}&dictKey=${item.dictKey}" data-title="编辑字典">编辑</a>
						<#if item.state != 1>
						<a href="javascript:;" class="ui-ico-tips ui-ico-unLock" onclick="tab.updateState(this,'1');" 
							data-id="${item.dictKey}"  data-url="updateState?dictCode=${param.dictCode}" data-tips="确定要启用该字典吗？" title="启用">启用</a> 
						<#else>
						<a href="javascript:;" class="ui-ico-tips ui-ico-lock" onclick="tab.updateState(this,'2');" 
							data-id="${item.dictKey}"  data-url="updateState?dictCode=${param.dictCode}" data-tips="确定要禁用该字典吗？" title="禁用">禁用</a>  
						</#if>
						<a href="javascript:;" class="ui-ico-tips ui-ico-delete" onclick="tab.del(this);" title="删除" 
                        	data-id="${item.dictKey}" data-url="delete?dictCode=${param.dictCode}" data-tips="确定删除该字典吗？">删除</a> 
					</td>
				</tr>
				</#list>
				<#else>
				<tr>
					<td colspan="11"><p class="no-data">没有相关数据</p></td>
				</tr>
			</#if>
			</tbody>
		</table>
		<div class="ui-page">
			<#include "/admin/common/page.html">
		</div>
	</div>
</form>
</@home.home>
</#escape>